# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=viper
pkgver=2099.fdd7855
pkgrel=5
groups=('blackarch' 'blackarch-disassembler' 'blackarch-binary'
        'blackarch-malware')
pkgdesc='A Binary analysis framework.'
arch=('any')
url='https://github.com/botherder/viper'
license=('custom')
depends=('python' 'python-magic' 'python-pefile' 'python-pydeep'
         'python-requests' 'python-sqlalchemy' 'python-pycryptodome'
         'python-beautifulsoup4' 'python-olefile' 'python-prettytable'
         'python-pypdns' 'python-pypssl' 'python-pype32' 'python-bottle'
         'python-pyexiftool' 'python-pylzma' 'python-pyelftools'
         'python-bitstring' 'python-dnspython' 'python-pyasn1' 'python-six'
         'python-pymisp' 'python-dateutil' 'python-requests-cache'
         'python-terminaltables' 'python-pydeep' 'python-ssdeep' 'ssdeep'
         'python-oletools' 'python-django' 'python-r2pipe' 'python-pbkdf2'
         'python-django-extensions' 'python-whitenoise' 'python-jsonschema'
         'python-rarfile' 'python-scandir' 'python-python-magic')
makedepends=('git' 'python-sphinx' 'python-pip' 'python-setuptools')
source=("git+https://github.com/botherder/$pkgname.git"
        'setup.py.patch')
sha512sums=('SKIP'
            '2f2a9ca216e17bd777e0049c67a9a54ac01ec36bcc8bdf4e35e1d5f344eae04a8667a044b42c76a8cb0b08b7c07bc588f7fa15c46b4209b1a740b4208fa42cf9')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  patch -p0 < "$srcdir/setup.py.patch"

  git submodule init
  git submodule update
}

build() {
  cd $pkgname

  python -m compileall .
  python -O -m compileall .
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  python setup.py install --record installed_files.txt --root="$pkgdir" -O1

  install -Dm 644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm README.md LICENSE

  cp -a * "$pkgdir/usr/share/$pkgname/"
}

